package org.naive.vstream.render;

public class DirectValueState extends RendererState {
	private byte readValue;

	private int currentBit;

	public DirectValueState() {
		super(0, 0, 0, 0);
	}

	@Override
	public void handleBit(boolean bit) {
		int v = bit ? 0b1 : 0b0;

		if (currentBit < 4) {
			readValue |= v << currentBit;
			currentBit++;
		}
		if (currentBit >= 4) {
			done();
		}
	}

	public int value() {
		return readValue;
	}
}
